#include <stdio.h>
//位运算符
int main() {
    short i=5; //short是整型，是2个字节的整型，int是4个字节
    short j;
    j = i << 1; //一个变量移动以后自身不会变化
    printf("j=%d\n",j); //左移是乘2，结果为5
    j = i >> 1; //右移是除2，结果是2,高位补0，低位丢弃
    printf("j=%d\n",j);
    printf("----------------\n");
    i = 0x8011; //十进制为-32751
    unsigned short s=0x8011; //无符号数,再short前加unsigned，不能是负数
    unsigned short r=0;
    j = i >> 1; //对i右移
    r = s >> 1;
    printf("j=%d,r=%d\n",j,r);
    printf("----------------\n");
    //按位与，按位或，按位异或，按位取反
    i=5,j=7;
    printf("i & j=%d\n",i & j);
    printf("i | j=%d\n",i | j);
    printf("i ^ j=%d\n",i ^ j);
    printf(" ~i =%d\n",~i);

    short a;
    scanf("%d",&a);
    printf("%2d\n",a<<1);
    printf("%2d\n",a>>1);

    //输入5个数，其中2个数出现2次，1个数是出现1次，找出出现1次的那个数
    // 例如输入的是8 5 3 5 8，输出的值为3
    int b[5];
    for (int i = 0; i < 5; ++i) {
        scanf("%d",&b[i]);
    }
    int result=0;
    for (int i = 0; i < 5; ++i) {
        result ^=b[i];
    }
    printf("%d", result);
    return 0;
}
